﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;

namespace Dycox.Drawing
{
    public class DiagramTextBlock : DiagramRectangle
    {
        public DiagramTextBlock(RectangleF rect)
            : base(rect)
        {

        }

        public DiagramTextBlock(RectangleF rect, string text)
            : this(rect)
        {
            this.Text = text;
        }

        public DiagramTextBlock(float left, float top, float width, float height)
            : this(new RectangleF(left, top, width, height))
        {

        }

        protected override void DrawContent(DrawShapeArgs args)
        {
            if (!string.IsNullOrWhiteSpace(Text))
            {
                Brush br = CreateTextBrush();
                if (br != null)
                {
                    StringFormat sf = CreateStringFormat();
                    Font font = this.Font ?? SystemFonts.DefaultFont;
                    RectangleF rect = _padding.Deflect(Bounds);

                    args.Graphics.DrawString(Text, font, br, rect, sf);

                    sf.Dispose();
                    br.Dispose();
                }
            }
            
        }

        private Paddings _padding;

        public Paddings Padding
        {
            get { return _padding; }
            set { _padding = value; }
        }

        
    }
}
